package com.zzz.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zhr
 */
public enum T {
    A("a"),
    B("b"),
    C("c"),
    D("d"),
    E("e"),
    ;

    public String code;
    private T(String code) {
        this.code = code;
        init(this);
    }

    private static Map<String, T> prop;
    private void init(T t) {
        if(prop == null) {
            prop = new HashMap<>();
        }
        prop.put(t.code, t);
    }

    public static T getFromCode(String code) {
        return prop.get(code);
    }

}
